﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using Wsitech.Model;
using Wsitech.Utility;
using Wsitech.BLL;
public partial class Backend_Admin_Login : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (CheckParams())
        {
            AdminUser user = AdminUserBLL.Instance.CheckAccount(txtUserName.Text.Trim(), txtPassword.Text.Trim());
            if (user != null)
            {
                if (user.State == (int)UtilityEnum.State.Enable)
                {
                    //登录成功 
                    Session["BackendUser"] = user;
                    Response.Redirect(GlobalConst.BACKEND_INDEX);
                }
                else
                {
                    //已禁用
                    lbMessage.Text = "该帐户已禁用！";
                }
            }
            else
            {
                lbMessage.Text = "用户名或密码不正确！";
                return;
            }
        }


        ////快捷登录
        //Session["BackendUser"] = new AdminUser();
        //Response.Redirect(GlobalConst.BACKEND_INDEX);
    }

    private bool CheckParams()
    {
        if (txtUserName.Text.Trim() == "")
        {
            lbMessage.Text = "用户名不能为空！";
            return false;
        }
        if (txtPassword.Text.Trim() == "")
        {
            lbMessage.Text = "用户密码不能为空！";
            return false;
        }
        return true;
    }
}
